<?php
/**
 *
 *
 */
class Page{
	public $id;
	public $lang;
	public $name;
	public $linkname;
	public $content;

	/**
	 * Constructor
	 */
	function __construct($id,$lang=LANG,$name,$linkname,$content){
		$this->id = $id;
		$this->lang = $lang;
		$this->name = $name;
		$this->linkname = $linkname;
		$this->content = $content;
	}

	public static function get($titre) {
		$query = "select * from pages where linkname = '".$titre."';";
		$res = DBselect($query);
		$page = new Page($res[0]["id"],$res[0]["lang"],$res[0]["name"],$res[0]["linkname"],$res[0]["content"]);
		return $page;
	}

	public static function getById($id) {
		$query = "select * from pages where id = '".$id."';";
		$res = DBselect($query);
		$page = new Page($res[0]["id"],$res[0]["lang"],$res[0]["name"],$res[0]["linkname"],$res[0]["content"]);
		return $page;
	}

	public static function getAll() {
		$query = "select * from pages;";
		$results = DBselect($query);
		$pages = array();
		foreach($results as $res){
			$pages[] = new Page($res["id"],$res["lang"],$res["name"],$res["linkname"],$res["content"]);
		}
		return $pages;
	}
}

?>